/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.service;

import br.ufc.quixada.adrs.dao.TipoDoencaDAO;
import br.ufc.quixada.adrs.model.TipoDoenca;
import br.ufc.quixada.adrs.util.Msg;
import java.sql.SQLException;
import java.util.List;
import org.slf4j.LoggerFactory;

/**
 *
 * @author Balthazar
 */
public class TipoDoencaService {

    private final TipoDoencaDAO dao = new TipoDoencaDAO();

    public void insertTipoDoenca(TipoDoenca tipoTipoDoenca) {
        try {
            dao.insert(tipoTipoDoenca);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
    }

    public void deleteTipoDoenca(Long id) {
        try {
            dao.delete(id);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
    }

    public TipoDoenca getTipoDoencaById(Long id) {
        try {
            return dao.getById(id);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
        return null;
    }

    public TipoDoenca getTipoDoencaByNome(String nome) {
        try {
            return dao.getByNome(nome);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
        return null;
    }

    public List<TipoDoenca> getAllTiposDoenca() {
        try {
            return dao.getAll();
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
        return null;
    }
}
